package com.springboot.study.tests;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @Author: guodong
 * @Date: 2021/10/2 16:50
 * @Version: 1.0
 * @Description:
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestBean {

    @Autowired
    private ConfigurableApplicationContext ioc;

    @Test
    public void testHelloService() {
        //测试Spring上下文环境中是否有testBeanService这样一个bean，有的话表示xml配置文件生效
        boolean testBeanService= ioc.containsBean("user1");
        Object o  = ioc.getBean("user1");
        Object o1  = ioc.getBean("user2");
        System.out.println(testBeanService);
        System.out.println(o.hashCode());
        System.out.println(o1.hashCode());
    }



}
